import java.util.Scanner;

public class NGuessNumber {

    private int[] playerArr = new int[4];
    private int[] arr = new int[4];
    private int a = 0;
    private int b = 0;

    public int[] generateAnswer() {
        this.a = 0;
        this.b = 0;
        int a, b, c, d;
        while(true){
            a = (int) (Math.random() * 9);
            b = (int) (Math.random() * 9);
            c = (int) (Math.random() * 9);
            d = (int) (Math.random() * 9);
            if (a != b && a != c && a != d && b != c && b != d) {
                arr = new int[]{a, b, c, d};
                break;
            }
        }
        return arr;
    }

    public int[] getPlayerInput() {
        System.out.println("请输入四个数字,之间用空格隔开");
        Scanner sc = new Scanner(System.in);
        for (int i = 0 ; i<playerArr.length ;i++){
            playerArr[i] = sc.nextInt();
        }
        return playerArr;
    }

    public int[] compareGuessAnswer() {
        a=0;
        b=0;
        for (int i = 0 ; i < arr.length ; i++){
            if (arr[i]==playerArr[i]){
                a++;
            }

            for (int j = 0 ; j < arr.length ; j++){
                if (i!=j){
                    if (arr[i]==playerArr[j]){
                        b++;
                    }
                }
            }
        }

        System.out.println(a+"A"+b+"B");
        return new int[]{a,b};
    }

    public boolean isWin() {
        if (a==4){
            System.out.println("你赢了！");
        }
        return a == 4;
    }

    public int[] setArr(int[] r){
        arr = r;
        return r;
    }
}
